<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-row>
      <el-col :span='22' :xs='24'>
        <el-form ref="form" :model="produce_info" :rules="rules" label-width="100px" id="mvcfm">
          <el-button @click="proDeviceUpSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
          <el-button @click="gotoPage('/mes/produce/ProDeviceDet?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 生产设备基本信息 </span>
          </div>
          <div>
            <el-row>
              <el-col :span="24">
                <el-form-item label="设备分类" prop="menu_class">
                  <el-radio-group v-model="produce_info.menu_class">
                    <el-radio-button label="生产设备">生产设备</el-radio-button>
                    <el-radio-button label="模具夹具">模具夹具</el-radio-button>
                  </el-radio-group>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="生产设备名称" prop="produce_name">
                  <el-input v-model="produce_info.produce_name" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="生产设备型号" prop="produce_model">
                  <el-input v-model="produce_info.produce_model" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="生产设备规格" prop="produce_norm">
                  <el-input v-model="produce_info.produce_norm" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="生产设备条形码" prop="produce_barcode">
                  <el-input v-model="produce_info.produce_barcode" readonly />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="供应商" prop="produce_supper">
                  <el-select style='width:100%' v-model="produce_info.produce_supper">
                    <el-option label="－－无－－" value='' />
                    <el-option v-for="dict in s_sname" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="制造商" prop="produce_maker">
                  <el-select style='width:100%' v-model="produce_info.produce_maker">
                    <el-option label="－－无－－" value='' />
                    <el-option v-for="dict in s_mname" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <div class="form-unit">
            <span class="mvc-title-left"> 附加说明 </span>
          </div>
          <div>
            <el-row>
              <el-col :span="24">
                <el-form-item label="简短描述" prop="produce_simdescribe">
                  <el-input v-model="produce_info.produce_simdescribe" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="具体描述" prop="produce_describe">
                  <el-input type="textarea" v-model="produce_info.produce_describe" ttparea=350></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <el-button @click="proDeviceUpSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
          <el-button @click="gotoPage('/mes/produce/ProDeviceDet?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
        </el-form>
      </el-col>
      <el-col :span='2' :xs='24'>
        <el-menu default-active='active' class='menu-unit'>
          <el-menu-item v-for='item in Container'>
            <el-link @click="gotoMenu(item.url)" :type="'生产设备信息'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
          </el-menu-item>
        </el-menu>
      </el-col>
    </el-row>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'ProDeviceUp',
    components: {},
    props: ['popparams'],
    data() {
      return {
        vueparams: this.getVUEParams(""),
        produce_info: {
          menu_class: null,
          produce_name: null,
          produce_model: null,
          produce_norm: null,
          produce_barcode: null,
          produce_supper: null,
          produce_maker: null,
          produce_simdescribe: null,
          produce_describe: null,
        },
        s_sname: [],
        s_mname: [],
        loading: false,
        Container: null,
        rules: {
          produce_name: [{
            required: true,
            message: "生产设备名称不能为空",
            trigger: 'blur',
          }],
        }
      }
    },
    created() {
      this.getData();
      this.loadContainerMenu({
        pid: "D797D94B97264F339A7F3838BB343F64",
        name: "生产设备右菜单",
        selected: "生产设备信息"
      }, 'Container', this.vueparams);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/produce/ProDeviceInfo/proDeviceUp?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      proDeviceUpSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/mes/produce/ProDeviceInfo/proDeviceUpSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/mes/produce/ProDeviceDet/proDeviceDet?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
    },
  }
</script>
